# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         less2_02
# Description:  类的继承
# Author:       asus
# Date:         2019/3/16
#-------------------------------------------------------------------------------


class Animal:
    def __init__(self):
        self.name = 'Animal'
        print('Animal 类')

    def eat(self):
        print('我在吃东西')


class Dog(Animal):
    def __init__(self):
        super(Dog,self).__init__() # super里面可以不写
        # 这里调用了父类的__init__构造方法
        print(self.name)
        print('Dog 类')

    def walk(self):
        print('我会走路')

    def eat(self):
        super().eat()
        print('狗爱吃骨头')
        # 这里不调用父类的eat方法，那么父类的方法会被覆盖


class Man:
    pass

if __name__ == '__main__':
    animal = Animal()
    animal.eat()
    print('----------------')
    dog = Dog()
    print('----------------')
    dog.eat()
    # 父类和子类方法相同时，可以使用super防止父类方法被覆盖
    dog.walk()

    print('----------------')
    print(issubclass(Dog,Animal))
    print('----------------')
    print(issubclass(Man,Animal))
